<html>
<head><meta charset="utf-8"><title>Examples · project-portable-simd · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/index.html">project-portable-simd</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html">Examples</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="224756941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224756941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224756941">(Feb 01 2021 at 17:00)</a>:</h4>
<p>Hi all, I would like to experiment with portable-simd :) is there any example of how to get started? Do I just need to install rust nightly and import it correctly?</p>



<a name="224757275"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224757275" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224757275">(Feb 01 2021 at 17:02)</a>:</h4>
<p>Yes, right now you would need to pull it directly from github since it's not in <a href="http://crates.io">crates.io</a> or the core library yet</p>



<a name="224758301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224758301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224758301">(Feb 01 2021 at 17:08)</a>:</h4>
<p>Ah okay, thanks a lot for the hint! I guess it should be possible to add it as a cargo git dependency?</p>



<a name="224758860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224758860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224758860">(Feb 01 2021 at 17:12)</a>:</h4>
<p>Yep. We use a cargo workspace so I'm not really sure how that works when specifying the dependency, I assume there's a way</p>



<a name="224759082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224759082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224759082">(Feb 01 2021 at 17:13)</a>:</h4>
<p>Okay great, will give it a try... <span aria-label="pray" class="emoji emoji-1f64f" role="img" title="pray">:pray:</span></p>



<a name="224759087"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224759087" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224759087">(Feb 01 2021 at 17:13)</a>:</h4>
<p>You can just point directly to the <code>Cargo.toml</code> of the crate you want to depend on.</p>



<a name="224759179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224759179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224759179">(Feb 01 2021 at 17:13)</a>:</h4>
<p>This crate seems also cool for experimenting with SIMD - although someone else can probably chime in wrt the tradeoffs vs <code>stdsimd</code>.<br>
<a href="https://github.com/AdamNiederer/faster">https://github.com/AdamNiederer/faster</a></p>



<a name="224799782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224799782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224799782">(Feb 01 2021 at 22:09)</a>:</h4>
<p>I strongly endorse Lokathor's  <a href="https://crates.io/crates/wide">https://crates.io/crates/wide</a> if you just want to use SIMD and mess around for a bit and not worry about deeper compiler nuances.</p>



<a name="224802398"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224802398" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224802398">(Feb 01 2021 at 22:26)</a>:</h4>
<p>Oh hot damn, it's Monday lol.</p>



<a name="224839693"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224839693" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224839693">(Feb 02 2021 at 08:15)</a>:</h4>
<p>Thanks a lot for the great input.<br>
I would be specifically interested in testing the experimental WebAssembly SIMD support. <span class="user-mention" data-user-id="281757">@Jubilee</span> <span class="user-mention" data-user-id="246783">@Miguel Raz Guzmán Macedo</span> do you know if Wide and Faster support WASM targets?<br>
It looks like Portable SIMD is developed with WebAssembly support in mind?</p>



<a name="224841431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224841431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224841431">(Feb 02 2021 at 08:36)</a>:</h4>
<p>For future reference, cargo seems to find the member crate of a workspace if you point it to the repository containing the workspace. So I was able to fetch core_simd via <code>core_simd = {git = "https://github.com/rust-lang/stdsimd"}</code></p>



<a name="224843387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224843387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224843387">(Feb 02 2021 at 08:59)</a>:</h4>
<p>Oh, WASM SIMD is highly experimental even in the browsers. I don't know, honestly, what you're going to get out of it.</p>



<a name="224853551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224853551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224853551">(Feb 02 2021 at 10:37)</a>:</h4>
<p>Yeah, I know. We are just evaluating what is already there for Rust vs C++/Emscripten. Basically, we want to get an idea on once WASM SIMD is more mature in the browsers, how good it seems to be supported by the tech-stack we are looking at. A Protable SIMD implementation would be definitely an advantage, but I would also have a quick look into <code>core::arch::wasm32</code> which probably would be a good fallback to target the WASM SIMD implementation directly. What do you think?</p>



<a name="224917191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224917191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224917191">(Feb 02 2021 at 18:46)</a>:</h4>
<p>plausible.<br>
I am not aware of core::arch's specific capabilities in this area or how those will change<br>
but I can say that I expect in the fullness of time that core::simd will probably pretty directly compile to wasm to the point where there's not as much use of core::arch instructions, because from what I'm aware of the WASM SIMD proposals, they are fairly conservative in terms of what instructions are available.</p>



<a name="224917647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224917647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Caleb Zulawski <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224917647">(Feb 02 2021 at 18:49)</a>:</h4>
<p>Since wasm is already "portable asm" it's unsurprising that two "portable SIMD" implementations would look similar :)</p>



<a name="224918673"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/224918673" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jubilee <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#224918673">(Feb 02 2021 at 18:55)</a>:</h4>
<p>indeed. ^^;<br>
I also can say that I expect the Emscripten environment... not the entire C++-to-WASM toolchain, some of which is also called "Emscripten", but rather specifically the Emscripten environment... to become less relevant over time, based on what other people have told me, as it is kind of the thing that WASI is aimed at being.</p>



<a name="225039312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/225039312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#225039312">(Feb 03 2021 at 16:20)</a>:</h4>
<p>Oh wow, that's great. Then there is definitely no need for us to look into core::arch...</p>



<a name="225039473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/225039473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#225039473">(Feb 03 2021 at 16:21)</a>:</h4>
<p>I've succeeded to get my hello-world example working. Maybe it's interesting for somebody else as well? It's tested on win64 and wasm32...<br>
<a href="https://github.com/haraldreingruber-dedalus/rust-protable-simd-hello-world">https://github.com/haraldreingruber-dedalus/rust-protable-simd-hello-world</a></p>
<p>If you have improvement ideas, feedback is always welcome :)</p>



<a name="225039661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/225039661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Harald Reingruber <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#225039661">(Feb 03 2021 at 16:22)</a>:</h4>
<p>By the way, this channel has 128 members. Congrats on filling up the full f32x4 size  <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<a name="225113999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/257879-project-portable-simd/topic/Examples/near/225113999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Miguel Raz Guzmán Macedo <a href="https://rust-lang.github.io/zulip_archive/stream/257879-project-portable-simd/topic/Examples.html#225113999">(Feb 04 2021 at 03:07)</a>:</h4>
<p><span class="user-mention silent" data-user-id="386014">Harald Reingruber</span> <a href="#narrow/stream/257879-project-portable-simd/topic/Examples/near/224841431">said</a>:</p>
<blockquote>
<p>For future reference, cargo seems to find the member crate of a workspace if you point it to the repository containing the workspace. So I was able to fetch core_simd via <code>core_simd = {git = "https://github.com/rust-lang/stdsimd"}</code></p>
</blockquote>
<p>This just saved me. Thanks!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>